
<script src="/js/jquery/jquery.raty.min.js"></script>
<style>
body,#maincontent{background: #f3f3f3;}
p{    line-height: 1.6em;margin: 0 0 6px;}
.star{width:200px !important;display: inline-block;text-align: center;}
.persent{display:inline-block;text-align: right;width:40px;padding:0 5px;}
.star-stat{margin: 10px 0;}
.txt-result{margin: 10px 0;background: #fafafa;padding:10px;margin-bottom: 10px}
h1{color:#127975;font-size:16sp;font-weight: bold;margin-bottom: 10px;}
h2{padding:10px 0;border-bottom:1px solid #c2c2c2;font-size:14sp;color:#333;font-weight: bold;}
h3{margin:10px 0;color:#333;font-size:16px;}
.fa-star,.fa-star-o{margin-right:5px;}
.mark-head{padding:5px 20px;margin-bottom: 15px;}
.mark-item {
    border-top: 1px solid #ddd;padding:5px 20px;
}
.star img { width: 20px;}
.error{border:1px solid red;}
.btn-primary{background-image: -webkit-linear-gradient(left, #149a4a, #0c9794); background-color: #127975;border:0 none;}
.form-control {background: #fafafa;}
.mark-item .text-center{font-size:16px;}
</style>
{{if $isWeixin}}
<script src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
<script>

wx.config({
    debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来，若要查看传入的参数，可以在pc端打开，参数信息会通过log打出，仅在pc端时才会打印。
    appId: "{{$signPackage['appId']}}", // 必填，公众号的唯一标识
    timestamp: {{$signPackage['timestamp']}}, // 必填，生成签名的时间戳
    nonceStr: "{{$signPackage['nonceStr']}}", // 必填，生成签名的随机串
    signature: "{{$signPackage['signature']}}",// 必填，签名，见附录1
    jsApiList: ['onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','onMenuShareQZone'] // 必填，需要使用的JS接口列表，所有JS接口列表见附录2
});

window.share_config = {
     "share": {
        "imgUrl": "{{$WxActivity['WxActivity']['coverimg']}}",//分享图，默认当相对路径处理，所以使用绝对路径的的话，“http://”协议前缀必须在。
        "desc" : "{{$WxActivity['WxActivity']['summary']?$WxActivity['WxActivity']['summary']:$pageTitle.'-'.$site[title]}}",//摘要,如果分享到朋友圈的话，不显示摘要。
        "title" : '{{$pageTitle}}',//分享卡片标题
        "link": window.location.href,//分享出去后的链接，这里可以将链接设置为另一个页面。
        "success":function(){//分享成功后的回调函数
        },
        'cancel': function () { 
            // 用户取消分享后执行的回调函数
        }
    }
};  

wx.ready(function(){
	wx.onMenuShareAppMessage(share_config.share);//分享给好友
    wx.onMenuShareTimeline(share_config.share);//分享到朋友圈
    wx.onMenuShareQQ(share_config.share);//分享给手机QQ
    wx.onMenuShareWeibo(share_config.share); //分享到微博
    wx.onMenuShareQZone(share_config.share); //分享到QQ空间
});

</script>

{{/if}}

{{$this->Form->create('ItemMark',array('url'=>array('action'=>'addScore',$ItemMark['ItemMark']['id']), 'onsubmit'=>"return addMark(this);",'id'=>'ItemMarkForm','role'=>'form'))}}
<div>
    <div>
        <div class="mark-head">
    	<h1>{{$ItemMark['ItemMark']['name']}}</h1>
    	<p>创建时间：{{$ItemMark['ItemMark']['created']}}</p>
        <p>截止时间：{{date('Y-m-d H:i:s',strtotime($ItemMark['ItemMark']['created'])+$ItemMark['ItemMark']['seconds'])}}</p>
        <p>创建老师：{{$ItemMark['ItemMark']['author']}}</p>
        </div>

        <div class="mark-item" id="item-mobile">
            <h3 class="question-head">输入手机号</h3>
            <input type="text" class="form-control" name="mobile">
        </div>
    		{{loop $mark_items $item}}
	      		<div class="mark-item" id="item-{{$item['field']}}">	      			
					<h3 class="question-head">{{$item['name']}}</h3>
					<p>{{$item['summary']}}</p>
					
					{{if $item['type']=='score'}}
					<div class="text-center">较差 <div class="star" data-field="{{$item['field']}}"></div> 优秀</div>
					<input type="hidden" require="require" name="{{$item['field']}}">
					{{elseif $item['type']=='textarea'}}
						<textarea rows="3" class="form-control" name="{{$item['field']}}"></textarea>
					{{else}}
						<input type="text" class="form-control" name="{{$item['field']}}">
					{{/if}}
				</div>
			{{/loop}}
		<p><br/></p>
		<p><br/></p>
	</div>
</div>	
<button class="btn btn-primary btn-block btn-lg navbar-fixed-bottom" >
	提交
</button>


{{$this->Form->end()}}


<script>

function addMark( form ){
    $('.mark-item').removeClass('error');
    var required = ['mobile','val1','val2','val3','val4','val5'];
    for(var i in required){
        if($('[name='+required[i]+']').val()=="") {

            $('#item-'+required[i]).addClass('error');
            $('[name='+required[i]+']').focus();
            showErrorMessage("检查各项是否都打分或填写了");
            return false;
        }
    }
    return ajaxSubmitForm(form);
}

$(function(){

	$('.star').raty({
		'path':'/img/',
		click: function(score, evt) {
            //alert('ID: ' + $(this).data('field') + "\nscore: " + score + "\nevent: " + evt.type);
            $('input[name='+ $(this).data('field') +']').val(score);
        }
	});
})

</script>